using System;
using System.Collections.Generic;
using System.Text;
using DTO;
using DAO;
using System.Data;

namespace BUS
{
    /// <summary> 
    ///Author: daiduong19051986@gmail.com 
    /// <summary>
    public class TVC_MVPControl
    {
        #region Local Variable
        private string business;
        private TVC_MVPDataAccess _objDAO;
        #endregion Local Variable

        #region Method

        public TVC_MVPControl(String bus)
        {
            business = bus;
            _objDAO = new TVC_MVPDataAccess();
        }

        public TVC_MVPInfo Get(string db, String Code, ref string sErr)
        {
            return _objDAO.Get(db, Code, ref sErr);
        }

        public DataTable GetAll(string db, ref string sErr)
        {
            return _objDAO.GetAll(db, ref sErr);
        }

        public Int32 Add(string db, TVC_MVPInfo obj, ref string sErr)
        {
            return _objDAO.Add(db, obj, ref sErr);
        }

        public string Update(string db, TVC_MVPInfo obj)
        {
            return _objDAO.Update(db, obj);
        }

        public string Delete(string db, String Code)
        {
            return _objDAO.Delete(db, Code);
        }
        public Boolean IsExist(string db, String Code)
        {
            return _objDAO.IsExist(db, Code);
        }


        public string InsertUpdate(string db, TVC_MVPInfo obj)
        {
            string sErr = "";
            if (IsExist(db, obj.Code))
            {
                sErr = _objDAO.Update(db, obj);
            }
            else _objDAO.Add(db, obj, ref sErr);
            return sErr;


        }

        public DataTable GetTransferOut(string dtb, object from, object to, ref string sErr)
        {
            return _objDAO.GetTransferOut(dtb, from, to, ref sErr);


        }

        public DataTable ToTransferInStruct()
        {
            //TVC_MVPInfo inf = new TVC_MVPInfo();
            return TVC_MVPInfo.ToDataTable();
        }

        public string TransferIn(string db, DataRow row)
        {
            TVC_MVPInfo inf = new TVC_MVPInfo(row);
            return InsertUpdate(db, inf);
        }
        #endregion Method

    }
}
